package com.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.javabean.Account;
import com.javabean.Product;
import com.service.ProductService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class ProductController {
    @Autowired
    ProductService productService;

    @RequestMapping("/product/findAll")
    public String findAll(HttpServletRequest request,@RequestParam(value = "page",defaultValue = "1") int page,@RequestParam(value = "page",defaultValue = "5")int limit){
        PageHelper.startPage(1,5);

        List<Product> all = productService.findAll();
        request.setAttribute("all", all);
        PageInfo<Product> pageInfo=new PageInfo<>(all);
        request.setAttribute("pageInfo",pageInfo);
        return "product/product-list";
    }
}
